"use strict";
const common_vendor = require("../../../common/vendor.js");
const api_evaluation_index = require("../../../api/evaluation/index.js");
const config_app = require("../../../config/app.js");
const stores_userInfo = require("../../../stores/userInfo.js");
if (!Array) {
  const _easycom_up_album2 = common_vendor.resolveComponent("up-album");
  const _easycom_up_divider2 = common_vendor.resolveComponent("up-divider");
  const _easycom_up_gap2 = common_vendor.resolveComponent("up-gap");
  const _easycom_up_list_item2 = common_vendor.resolveComponent("up-list-item");
  const _easycom_up_empty2 = common_vendor.resolveComponent("up-empty");
  const _easycom_up_list2 = common_vendor.resolveComponent("up-list");
  const _easycom_up_modal2 = common_vendor.resolveComponent("up-modal");
  const _easycom_up_toast2 = common_vendor.resolveComponent("up-toast");
  (_easycom_up_album2 + _easycom_up_divider2 + _easycom_up_gap2 + _easycom_up_list_item2 + _easycom_up_empty2 + _easycom_up_list2 + _easycom_up_modal2 + _easycom_up_toast2)();
}
const _easycom_up_album = () => "../../../node-modules/uview-plus/components/u-album/u-album.js";
const _easycom_up_divider = () => "../../../node-modules/uview-plus/components/u-divider/u-divider.js";
const _easycom_up_gap = () => "../../../node-modules/uview-plus/components/u-gap/u-gap.js";
const _easycom_up_list_item = () => "../../../node-modules/uview-plus/components/u-list-item/u-list-item.js";
const _easycom_up_empty = () => "../../../node-modules/uview-plus/components/u-empty/u-empty.js";
const _easycom_up_list = () => "../../../node-modules/uview-plus/components/u-list/u-list.js";
const _easycom_up_modal = () => "../../../node-modules/uview-plus/components/u-modal/u-modal.js";
const _easycom_up_toast = () => "../../../node-modules/uview-plus/components/u-toast/u-toast.js";
if (!Math) {
  (_easycom_up_album + _easycom_up_divider + _easycom_up_gap + _easycom_up_list_item + _easycom_up_empty + _easycom_up_list + _easycom_up_modal + _easycom_up_toast)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "allEvaluation",
  setup(__props) {
    const userInfoStore = stores_userInfo.useUserInfoStore();
    const uToastRef = common_vendor.ref(null);
    const data = common_vendor.reactive({
      queryParam: {
        pageNum: 1,
        pageSize: 10,
        userId: userInfoStore.userInfo.userId
      },
      list: [],
      total: 0,
      showDel: false,
      delIds: void 0
    });
    const { queryParam, list, total, showDel, delIds } = common_vendor.toRefs(data);
    common_vendor.onLoad(() => {
      getEvaluationList();
    });
    const scrolltolower = () => {
      let allTotal = queryParam.value.pageNum * queryParam.value.pageSize;
      if (allTotal >= total.value) {
        return;
      }
      queryParam.value.pageNum = ++queryParam.value.pageNum;
      getEvaluationList();
    };
    const getEvaluationList = () => {
      common_vendor.index.showLoading({
        title: "加载中",
        mask: true
      });
      api_evaluation_index.listEvaluationHis(queryParam.value).then((res) => {
        common_vendor.index.hideLoading();
        const { data: data2 } = res;
        data2.records = data2.records ?? [];
        data2.records = arrProcess(data2.records);
        list.value = [...list.value, ...data2.records];
        total.value = data2.total;
      }).catch((err) => {
        common_vendor.index.hideLoading();
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const arrProcess = (arr) => {
      if (arr.length) {
        arr = arr.map((item) => {
          let badgeNumberArr = [];
          let policeNameArr = [];
          if (item.badgeNumber && item.badgeNumber.includes("、")) {
            badgeNumberArr = item.badgeNumber.split("、");
          }
          if (item.policeName && item.policeName.includes("、")) {
            policeNameArr = item.policeName.split("、");
          }
          item.users = [];
          if (badgeNumberArr.length && policeNameArr.length) {
            policeNameArr.forEach((it, index) => {
              item.users.push(
                it + " " + badgeNumberArr[index] + "（" + item.communityName + "）"
              );
            });
          } else {
            item.users.push(
              item.policeName + " " + item.badgeNumber + "（" + item.communityName + "）"
            );
          }
          if (item.imgUrl) {
            item.imgUrl = item.imgUrl.split(",");
            if (item.imgUrl.length) {
              item.imgUrl = item.imgUrl.map((img) => {
                img = config_app.imgPrefix + img;
                return img;
              });
            }
          }
          return item;
        });
      }
      return arr;
    };
    const deleteEvaluation = () => {
      api_evaluation_index.delEvaluation(delIds.value).then((res) => {
        resetModal();
        uToastRef.value.show({
          type: "success",
          message: "删除成功"
        });
        list.value = [];
        total.value = 0;
        getEvaluationList();
      }).catch((err) => {
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const resetModal = () => {
      showDel.value = false;
      delIds.value = void 0;
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.unref(list).length
      }, common_vendor.unref(list).length ? {
        b: common_vendor.f(common_vendor.unref(list), (item, index, i0) => {
          return common_vendor.e({
            a: common_vendor.t(item.users.join("、")),
            b: common_vendor.t(item.content),
            c: item.imgUrl && item.imgUrl.length
          }, item.imgUrl && item.imgUrl.length ? {
            d: "fb4a09b1-2-" + i0 + "," + ("fb4a09b1-1-" + i0),
            e: common_vendor.p({
              urls: item.imgUrl,
              space: "20rpx",
              singleSize: "155rpx",
              multipleSize: "155rpx",
              autoWrap: true,
              maxCount: 3,
              unit: "rpx"
            })
          } : {}, {
            f: common_vendor.t(item.createTime ? common_vendor.unref(common_vendor.dayjs)(item.createTime).format("YYYY-MM-DD hh:mm:ss") : ""),
            g: "fb4a09b1-3-" + i0 + "," + ("fb4a09b1-1-" + i0),
            h: common_vendor.o(($event) => {
              showDel.value = true;
              delIds.value = item.id;
            }, index),
            i: "fb4a09b1-4-" + i0 + "," + ("fb4a09b1-1-" + i0),
            j: index,
            k: "fb4a09b1-1-" + i0 + ",fb4a09b1-0"
          });
        }),
        c: common_vendor.p({
          lineColor: "#BBBBBB"
        }),
        d: common_vendor.p({
          height: "10"
        })
      } : {
        e: common_vendor.p({
          mode: "data",
          text: "暂无记录",
          icon: "http://cdn.uviewui.com/uview/empty/data.png"
        })
      }, {
        f: common_vendor.o(scrolltolower),
        g: common_vendor.p({
          height: "100vh"
        }),
        h: common_vendor.o(($event) => deleteEvaluation()),
        i: common_vendor.o(resetModal),
        j: common_vendor.o(resetModal),
        k: common_vendor.p({
          show: common_vendor.unref(showDel),
          title: "删除确认",
          content: "请问是否确认删除该条服务评价？",
          closeOnClickOverlay: true,
          contentTextAlign: "center",
          showCancelButton: true
        }),
        l: common_vendor.sr(uToastRef, "fb4a09b1-7", {
          "k": "uToastRef"
        })
      });
    };
  }
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-fb4a09b1"]]);
wx.createPage(MiniProgramPage);
